<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.fandy.struts.DAL.*"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.io.PrintWriter"%>

<%@page import="com.fandy.struts.Meta.GoodsInfo"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<%!public com.fandy.struts.Model.GoodsInfo SetGI(
			com.fandy.struts.Model.GoodsInfo gInfo, ResultSet rs)
			throws SQLException {
		gInfo.setBrand(rs.getString(GoodsInfo.getBrand()));
		gInfo.setGoodsid(rs.getInt(GoodsInfo.getGoodsid()));
		gInfo.setImage(rs.getString(GoodsInfo.getImage()));
		gInfo.setOrigin(rs.getString(GoodsInfo.getOrigin()));
		gInfo.setProfit(rs.getFloat(GoodsInfo.getProfit()));
		gInfo.setSize(rs.getString(GoodsInfo.getSize()));
		gInfo.setType(rs.getString(GoodsInfo.getType()));
		gInfo.setUnit(rs.getString(GoodsInfo.getUnit()));

		return gInfo;
	}%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
	<html:base />

	<title>ShowGoods.jsp</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	&nbsp;
<jsp:include page="../MasterPages/Header.jsp"   />
<div align="right"> <a href="../GoodsManagement/ManageGoods.jsp">商品管理</a> </div>
<hr />
	<div id="tittle" align="center">
		商品信息
	</div>

	<div id="Search" align="center">
		<table cellpadding=0 cellspacing=0 style="margin-left: 15px">
			<tr valign=top>
				<td style="height: 62px; padding-left: 92px" nowrap>
					<form name=f action="Search.do" method="post">
						<input type=text name="keyword"  size=42 maxlength=100>
						<input type=submit value=找找看 id=sb>
						<span id=hp> <br>
						</span>
					</form>
				</td>
			</tr>
		</table>

	</div>
	<div id="Goods" align="center">

		<table>
			<%
				DALGoodsInfo gi = new DALGoodsInfo();
					ResultSet rs  = null;
					
					com.fandy.struts.Model.GoodsInfo gInfo = new com.fandy.struts.Model.GoodsInfo();
					
					int i=-1 ;
					
					try
					{						 
						i = Integer.valueOf( request.getParameter("id"));
					}
					catch(Exception e)
					{
						e.printStackTrace();
					}
					if(session.getAttribute("ResultSet")==null && i==-1)
					{
						rs = gi.GetAllGoodsInfo();
					}
					else if(i!=-1)
					{
						rs = gi.GetGoodsByID(i);
					}
					else
					{
						rs = (ResultSet) session.getAttribute("ResultSet");
						session.removeAttribute("ResultSet");
					}
					while (rs.next()) {
						gInfo = SetGI(gInfo, rs);
			%>
			<tr>
				<td align="center" width="180">
					<a href="ShowGoods.jsp?id=<%=gInfo.getGoodsid()%>" target="_Blank"><img
							height="125" width="105" alt="<%=gInfo.getBrand()%>"
							src="../<%=gInfo.getImage()%>"> </a>
				</td>
				<td align="left" width="200">
					<table height="125">
						<tr valign="top">
							<td rowspan="1">
								<a href="ShowGoods.jsp?id=<%=gInfo.getGoodsid()%>"
									target="_Blank"><%=gInfo.getBrand() + " " + gInfo.getType()%>
								</a>
							</td>
						</tr>
						<tr>
							<td rowspan="1">
								产地:
								<%=gInfo.getOrigin()%>
							</td>
						</tr>
						<tr>
							<td rowspan="1">
								单位:<%=gInfo.getUnit()%>
							</td>

						</tr>
						<tr>
							<td rowspan="1">
								规格:<%=gInfo.getSize()%>
							</td>

						</tr>


					</table>

				</td>
				<%
					if (rs.next()) {
								gInfo = SetGI(gInfo, rs);
							} else {
								continue;
							}
				%>
				<td align="center">
					<a href="ShowGoods.jsp?id=<%=gInfo.getGoodsid()%>" target="_Blank"><img
							height="125" width="105" alt="<%=gInfo.getBrand()%>"
							src="../<%=gInfo.getImage()%>"> </a>
				</td>
				<td align="left" width="200">
					<table height="125">
						<tr valign="top">
							<td rowspan="1">
								<a href="ShowGoods.jsp?id=<%=gInfo.getGoodsid()%>"
									target="_Blank"><%=gInfo.getBrand() + " " + gInfo.getType()%>
								</a>
							</td>
						</tr>
						<tr>
							<td rowspan="1">
								产地:
								<%=gInfo.getOrigin()%>
							</td>
						</tr>
						<tr>
							<td rowspan="1">
								单位:<%=gInfo.getUnit()%>
							</td>

						</tr>
						<tr>
							<td rowspan="1">
								规格:<%=gInfo.getSize()%>
							</td>

						</tr>


					</table>

				</td>

			</tr>
<tr>
				<td colspan="8">
					<hr />
				</td>

			</tr>
			<%
				}
			%>
		</table>

	</div>
<jsp:include page="../MasterPages/Footer.jsp" />
</body>
</html:html>







